package com.lzl.servicedriveruser.service;

import com.lzl.constant.CommonStatusEnum;
import com.lzl.dto.DriverUser;
import com.lzl.responese.ResponseResult;
import com.lzl.servicedriveruser.mapper.DriverUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzl
 * @since 2022-08-30
 */
@Service
public class DriverUserServiceImpl {

    @Autowired
    DriverUserMapper driverUserMapper;

    public ResponseResult insertDriverUser(DriverUser driverUser){
        LocalDateTime now = LocalDateTime.now();
        driverUser.setGmtCreate(now);
        driverUser.setGmtModified(now);
        driverUserMapper.insert(driverUser);
        return ResponseResult.success("插入成功");
    }

    public ResponseResult updateDriverUser(DriverUser driverUser){
        LocalDateTime now = LocalDateTime.now();
        driverUser.setGmtModified(now);
        int i = driverUserMapper.updateById(driverUser);
        if(i==0){
            return ResponseResult.fail(CommonStatusEnum.UPDATE_INFO_ERROR.getCode(),CommonStatusEnum.UPDATE_INFO_ERROR.getValue());
        }
        return ResponseResult.success("修改成功");
    }
}
